<?php

/**
 * This is the model class for table "{{user_facebook}}".
 *
 * The followings are the available columns in table '{{user_facebook}}':
 * @property string $user_id
 * @property string $fb_user_id
 * @property string $username
 * @property string $name
 * @property string $first_name
 * @property string $last_name
 * @property string $primary_email
 * @property string $join_date
 * @property string $birthday
 * @property string $address
 * @property string $cell_phone
 * @property string $personal_identity
 */
class UserFacebook extends CActiveRecord
{
	public static function model($className=__CLASS__) {return parent::model($className);}
	public function tableName() {return '{{user_facebook}}';}
	public function rules()
	{
		// Define only rules for those attributes that will receive user inputs.
		return array(
			array('user_id, fb_user_id, name, last_name', 'required'),
			array('user_id, fb_user_id, cell_phone', 'length', 'max'=>20),
			array('username', 'length', 'max'=>60),
			array('name, primary_email', 'length', 'max'=>100),
			array('first_name, last_name', 'length', 'max'=>50),
			array('join_date, birthday, personal_identity', 'length', 'max'=>10),
			array('address', 'length', 'max'=>500),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('user_id, fb_user_id, username, name, first_name, last_name, primary_email, join_date, birthday, address, cell_phone, personal_identity', 'safe', 'on'=>'search'),
		);
	}

	public function relations()
	{
		return array(
		);
	}
	
	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'user_id' 			=> Yii::t('userfacebook', 'User'),
			'fb_user_id'	 	=> Yii::t('userfacebook', 'Fb User'),
			'username' 			=> Yii::t('userfacebook', 'Username'),
			'name' 				=> Yii::t('userfacebook', 'Name'),
			'first_name' 		=> Yii::t('userfacebook', 'First Name'),
			'last_name' 		=> Yii::t('userfacebook', 'Last Name'),
			'primary_email' 	=> Yii::t('userfacebook', 'Primary Email'),
			'join_date' 		=> Yii::t('userfacebook', 'Join Date'),
			'birthday' 			=> Yii::t('userfacebook', 'Birthday'),
			'address' 			=> Yii::t('userfacebook', 'Address'),
			'cell_phone' 		=> Yii::t('userfacebook', 'Cell Phone'),
			'personal_identity' => Yii::t('userfacebook', 'Personal Identity'),
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('user_id',$this->user_id,false);
		$criteria->compare('fb_user_id',$this->fb_user_id,false);
		$criteria->compare('username',$this->username,true);
		$criteria->compare('name',$this->name,true);
		$criteria->compare('first_name',$this->first_name,true);
		$criteria->compare('last_name',$this->last_name,true);
		$criteria->compare('primary_email',$this->primary_email,true);
		$criteria->compare('join_date',$this->join_date,true);
		$criteria->compare('birthday',$this->birthday,true);
		$criteria->compare('address',$this->address,true);
		$criteria->compare('cell_phone',$this->cell_phone,true);
		$criteria->compare('personal_identity',$this->personal_identity,true);

		return new CActiveDataProvider(get_class($this), array(
			'criteria'=>$criteria,
			'sort'=>array('defaultOrder'=>'user_id DESC'),
			'pagination'=>array('pageSize'=>Yii::app()->session->get('adminPageSize',25)),
		));
	}
}